<template>
	<view class="page">
		<view class="form-content">
			<u-form :model="formData" ref="uForm" class="uForm" label-position="top">
				<u-form-item prop="customerName" label="企业名称" label-width="auto">
					<u-input v-model="formData.customerName" placeholder="请输入企业名称" />
				</u-form-item>
				<u-form-item prop="socialCreditCode" label="统一社会信用代码" label-width="auto">
					<u-input v-model="formData.socialCreditCode" placeholder="请输入统一社会信用代码" />
				</u-form-item>
				<u-form-item prop="linkName" label="企业联系人" label-width="auto">
					<u-input v-model="formData.linkName" placeholder="请输入企业联系人" />
				</u-form-item>
				<u-form-item prop="mobilePhone" label="联系人手机号" label-width="auto">
					<u-input v-model="formData.mobilePhone" maxlength="11" placeholder="请输入联系人手机号" />
				</u-form-item>
				<!-- 	<u-form-item prop="legalRepresentative" label="法定代表人" label-width="auto">
					<u-input v-model="formData.legalRepresentative" placeholder="请输入法定代表人" />
				</u-form-item>
				<u-form-item prop="establishmentDate" label="成立日期" label-width="auto">
					<dateTime v-model="formData.establishmentDate" :showLabel="false" :showArrow="false"
						:required="false" :disabled="true" className="new-date-picker" placeholder="请选择成立日期"
						jnpfKey="date"></dateTime>
				</u-form-item>
				<u-form-item prop="registeredCapital" label="注册资本" label-width="auto">
					<u-input v-model="formData.registeredCapital" placeholder="请输入注册资本" type="digit" />
					<view slot="right">万元</view>
				</u-form-item>
				<u-form-item prop="industryClassification" label="行业分类" label-width="auto">
					<u-input v-model="formData.industryClassification" placeholder="请输入行业分类" />
				</u-form-item> -->
			</u-form>
		</view>
		<view class="save-bottom">
			<view class="fixed-btn save-padding">
				<u-button type="primary" shape="circle" @click="onSubmit">确定</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	import dateTime from '@/components/dateTime/dateTime.vue'
	const apiUrl = "/api/Jiushi/Customerbase";
	export default {
		components: {
			dateTime
		},
		name: 'customerBase',
		data() {
			return {
				formData: {
					businessId: this.$helper.getUuid(),
					customerName: null,
					linkName: null,
					mobilePhone: null,
					socialCreditCode: null,
					establishmentDate: null,
					legalRepresentative: null,
					registeredCapital: null,
					registeredAddress: null,
					customerProfile: null,
					industryClassification: null,
					actualBusinessAddress: null,
					actualBusinessPreArea: null,
					actualControllerId: null,
					mainProducts: null
				},
				rules: {
					customerName: [{
						required: true,
						message: '请输入企业名称',
						trigger: ['change', 'blur'],
					}],
					linkName: [{
						required: true,
						message: '请输入企业联系人',
						trigger: ['change', 'blur'],
					}],
					mobilePhone: [{
						required: true,
						message: '请输入联系人手机号',
						trigger: ['change', 'blur'],
					}, {
						validator: (rule, value, callback) => {
							return this.$u.test.mobile(value);
						},
						message: '联系人手机号码不正确',
						trigger: ['change', 'blur'],
					}],
					socialCreditCode: [{
						required: true,
						message: '请输入统一社会信用代码',
						trigger: ['change', 'blur'],
					}]
				},
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		methods: {
			/* 表单提交 */
			onSubmit() {
				this.$refs.uForm.validate(valid => {
					if (valid) {
						let url = apiUrl;
						let method = "POST";
						this.$helper.ajax({
							url: url,
							method: method,
							contentType: "application/json",
							data: this.formData,
							success: res => {
								this.$helper.msg('保存成功', 'success');
								uni.navigateBack();
							}
						});
					}
				});
			},
		}
	}
</script>

<style>

</style>